﻿using System;
using NUnit.Framework;
using ScrumBox.Model;

namespace ScrumBox.UnitTests.Model
{
    [TestFixture]
    public class SprintTester
    {
        [Test]
        public void CanCreateSprint()
        {
            var projectKey = "MyProject";
            var sprintTitle = "New Sprint";
            var startDate = DateTime.Now;
            var endDate = DateTime.Now + TimeSpan.FromDays(14);
            var sprintKey = string.Format("{0}-{1}", projectKey, sprintTitle);
            var sprint = new Sprint(sprintKey, sprintTitle, startDate, endDate);
            
            Assert.AreEqual(sprint.Title, sprintTitle);
            Assert.AreEqual(sprint.StartDate, startDate);
            Assert.AreEqual(sprint.EndDate, endDate);
        }

        [Test]
        public void CanAddSprintBackLogItems()
        {
            var projectKey = "MyProject";
            var sprintTitle = "Sprint 12";
            var sprintKey = string.Format("{0}-{1}", projectKey, sprintTitle);
            var sprint = new Sprint(sprintKey, sprintTitle, DateTime.Now, DateTime.Now + TimeSpan.FromDays(14));
            sprint.AddBackLogItem(new SprintBackLogItem());
            sprint.AddBackLogItem(new SprintBackLogItem());
            sprint.AddBackLogItem(new SprintBackLogItem());
            var sprintBackLogItem = new SprintBackLogItem(sprint);
            sprint.AddBackLogItem(sprintBackLogItem);
            Assert.That(sprint.GetSprintBackLogItems().Count == 4);
            Assert.That(sprint.GetSprintBackLogItems().Contains(sprintBackLogItem));
        }
    }
}